package com.guochenglang.www.service;

import com.guochenglang.www.pojo.Dialog;
import com.guochenglang.www.service.anotate.Affair;

import java.sql.SQLException;
import java.util.ArrayList;

/**
 * @author GuoChenglang
 */
public interface DialogService {
    /**
     * 获得未读信息
     *
     * @param userId 用户id
     * @return 未读信息列表
     * @throws SQLException           sql异常
     * @throws InterruptedException   断点异常
     * @throws IllegalAccessException 非法访问异常
     * @throws InstantiationException 实现异常
     */
    ArrayList<Dialog> dialogNoRead(Integer userId) throws SQLException, InterruptedException, IllegalAccessException, InstantiationException;

    /**
     * 获取未读消息个数
     *
     * @param userId 用户id
     * @return 未读消息个数
     * @throws SQLException           sql异常
     * @throws InterruptedException   断点异常
     * @throws IllegalAccessException 非法访问异常
     * @throws InstantiationException 实现异常
     */
    int dialogNoReadCount(Integer userId) throws SQLException, InterruptedException, IllegalAccessException, InstantiationException;

    /**
     * 获取聊天信息
     *
     * @param userId    用户id
     * @param anotherId 另一个用户id
     * @return 聊天信息列表
     * @throws SQLException           sql异常
     * @throws InterruptedException   断点异常
     * @throws IllegalAccessException 非法访问异常
     * @throws InstantiationException 实现异常
     */
    ArrayList<Dialog> allDialog(Integer userId, Integer anotherId) throws SQLException, InterruptedException, IllegalAccessException, InstantiationException;

    /**
     * 添加未读消息
     *
     * @param userId    用户id
     * @param anotherId 另一个用户id
     * @param message   聊天信息
     * @return 添加的主键
     * @throws SQLException           sql异常
     * @throws InterruptedException   断点异常
     * @throws IllegalAccessException 非法访问异常
     */
    @Affair
    int noRead(Integer userId, Integer anotherId, String message) throws SQLException, InterruptedException, IllegalAccessException;

    /**
     * 添加已读消息
     *
     * @param useId     用户id
     * @param anotherId 另一个用户id
     * @param message   消息
     * @return 添加的主键
     * @throws SQLException           sql异常
     * @throws InterruptedException   断点异常
     * @throws IllegalAccessException 非法访问异常
     */
    @Affair
    int isRead(Integer useId, Integer anotherId, String message) throws SQLException, InterruptedException, IllegalAccessException;

    /**
     * 更新会话为已读
     *
     * @param dialogId 会话id
     * @return 更新行数
     * @throws SQLException           sql异常
     * @throws InterruptedException   断点异常
     * @throws IllegalAccessException 非法访问异常
     */
    @Affair
    int updateDialog(Integer dialogId) throws SQLException, InterruptedException, IllegalAccessException;

}
